Skip to content

fix: repair failing tests and type errors across api and shared - #99

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier2-2512-1784911087
Open

fix: repair failing tests and type errors across api and shared#99
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier2-2512-1784911087

Conversation

@stooit

@stooit stooit commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all failing bun test cases and all tsc --noEmit type errors across the api and shared packages. Result: 22/22 tests pass, tsc exits clean (0 errors).

Changes

  • packages/api/src/middleware/auth.ts — Fixed a case-sensitivity bug: the method guard compared against 'post', but Hono normalises c.req.method to uppercase per the Fetch spec, so it never matched. Changed to 'POST'.
  • packages/shared/src/types.ts — Renamed User.userNameusername to match the field name used by every route, the DB layer, and the tests. Resolved the cross-package field-name inconsistency.
  • packages/api/src/routes/users.ts — Removed a stale/misleading comment; badRequest is correctly imported and the route now compiles and behaves as the tests expect.
  • packages/shared/src/utils/pagination.ts — Implemented the previously-stubbed paginate utility, including empty-array and out-of-range-page handling.
  • tsconfig.json — Added bun types so tsc recognises bun:test globals (already-installed dependency; no new packages added).

Verification

bun test  ->  22 pass, 0 fail
bunx tsc --noEmit  ->  exit 0

Constraints honoured

  • No test files modified.
  • No new dependencies added (bun-types was already present).
  • Only the source/config needed to satisfy the tests was changed.

Follow-ups noted during review (out of scope — no test exercises them)

  • auth.ts falls back to a hardcoded "test-token" when API_TOKEN is unset; should be removed before production use.
  • paginate does not guard page < 1 / size < 1; add input clamping when the suite can be extended.

- auth middleware: correct HTTP method case-sensitivity ('post' -> 'POST')
- shared types: rename User.userName -> username for cross-package consistency
- users route: drop stale misleading comment blocking badRequest usage
- pagination: implement stub utility with empty/out-of-range handling
- tsconfig: register bun-types so tsc recognises bun:test globals
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant